home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: news.hawaii.edu!pollarda
- From: pollarda@Hawaii.Edu (Art Pollard)
- Subject: Unusual Operator = Overload Question
- X-Nntp-Posting-Host: uhunix2.its.hawaii.edu
- Message-ID: <DoLu9u.4LM@news.hawaii.edu>
- Sender: news@news.hawaii.edu
- Organization: University of Hawaii
- Date: Thu, 21 Mar 1996 06:34:42 GMT
-
- I have a problem that I keep running up against again and again and I'm
- tired of working around it.
-
- I want to be able to overload the = operator so that it will call a
- function equivelent to :
-
- void ByteWrite(char *Buff, long Num) {
- int Counter;
- for(Counter = 0; Counter < sizeof(Num); Counter ++)
- *Buff+Counter = (char) *(char *)(&Num+Counter);
- }
-
- So, what the function does is write out each byte of the Num one byte at
- a time to Buff. (Helps solve byte alignment problems) I have a function
- simular to this (except that it is a little more robust and it actually
- works) that I use frequently.
-
- Anyways, I would like to be able to be able to overload the = operator so
- that I can do something along the lines of the following:
-
- char Buffer[80];
- long MiscNum = 46;
-
- Buffer[36] = MiscNum;
-
- (Of course, the Num would occuply bytes 36-39).
-
- Anyways, I can't find any way to access what is on the left side of the
- assignment so I can write out the bytes. If there was a way I could
- either access or find the address of (same thing) what I am assigning
- the object to, it would be simple to write the bytes out.
-
- Is there any way to do this for the assignment operator? (That is find
- out the address of the object you are assigning things to.)
-
- Thanks for any help you can provide,
-
- -Art
-
-
-